﻿namespace Mars.Event
{
    /// <summary>
    /// 事件结点。
    /// </summary>
    public sealed class EventNode<T> where T : BaseEventArgs
    {
        private object _sender = null;
        private T _eventArgs = null;

        /// <summary>
        /// 发送者
        /// </summary>
        public object Sender
        {
            get { return _sender; }
        }

        /// <summary>
        /// 事件参数
        /// </summary>
        public T EventArgs
        {
            get { return _eventArgs; }
        }

        /// <summary>
        /// 创建事件节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        /// <returns></returns>
        public static EventNode<T> Create(object sender, T eventArgs)
        {
            var eventNodeNode = new EventNode<T>
            {
                _sender = sender,
                _eventArgs = eventArgs
            };
            return eventNodeNode;
        }

        public void Clear()
        {
            _sender = null;
            _eventArgs = null;
        }
    }
}